<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252" %>
<!--#include file="common/connStr-s.asp" -->
<%

function Rename() {
    var id = Request.Form("id");
    if (id == "" || id == 'undefined') {
        return;
    }
    var comObj = Server.CreateObject('ADODB.Command');
    
    var cmdStr = ""
    var title = Request.Form("name");
    comObj.parameters.append(comObj.createParameter("@Title", 202, 0x0001, 150, title));
    comObj.parameters.append(comObj.createParameter("@PhotoID", 3, 0x0001, 8, id));
    cmdStr = "UPDATE dbo.PhotoAlbums SET AlbumName=? WHERE AlbumID = ?"
    
    comObj.CommandText = cmdStr;
    comObj.ActiveConnection = connStr;
    comObj.Execute();
    comObj.ActiveConnection.Close();
    delete comObj;
}
function Create() {
    var albumId = 0;
    var InsertedAlbumName = '';
    var response = [];
    var username = Request.Form("username");
    var name = Request.Form("name");
    if (username == "" || username == 'undefined') {
        return;
    }
    var comObj = Server.CreateObject('ADODB.Command');

    var cmdStr = ""

    comObj.parameters.append(comObj.createParameter("@Username", 202, 0x0001, 50, username));
    comObj.parameters.append(comObj.createParameter("@AlbumName", 202, 0x0001, 150, name));
    comObj.parameters.append(comObj.createParameter("@AlbumId", 3, 0x0002, 8));
    comObj.parameters.append(comObj.createParameter("@InsertedAlbumName", 202, 0x0002, 150)); 

    cmdStr = "CreateAlbum"

    comObj.CommandText = cmdStr;
    comObj.CommandType = 0x0004;

    comObj.ActiveConnection = connStr;
    comObj.Execute();

    albumId = comObj.parameters("@AlbumId");
    insertedAlbumName = comObj.parameters("@InsertedAlbumName");
    
    comObj.ActiveConnection.Close();
    delete comObj;

    return albumId + ";" + insertedAlbumName;
}
var action = Request.Form("action")
if (action == 1) {
    Rename();
}
if (action == 2) {
    Response.Write(Create());
}
%>